package com.zy.cat.entity.dev.repository;


import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.zy.cat.entity.dev.CatDevUserTaskRecord;
 
public interface CatDevUserTaskRecordRepository extends JpaSpecificationExecutor<CatDevUserTaskRecord>,  JpaRepository<CatDevUserTaskRecord, String>{
	
	List<CatDevUserTaskRecord> findByPidOrderByTaskType(String pid);
	
	List<CatDevUserTaskRecord> findByPidAndTaskAttributeOrderByTaskType(String pid,int taskAttribute);
	
	List<CatDevUserTaskRecord> findByPidAndTaskAttributeAndReceiveStatusOrderByTaskType(String pid,int taskAttribute,int receiveStatus);
	
	CatDevUserTaskRecord findByPidAndTaskType(String pid,int taskType);
	
	@Query("from CatDevUserTaskRecord where pid=:pid AND task_attribute=:taskAttribute AND DATE_FORMAT(ctime,'%Y-%m-%d')=CURRENT_DATE ORDER BY task_type")
	List<CatDevUserTaskRecord> queryByPidAndTaskAttributeOrderByTaskType(String pid,int taskAttribute);

	@Query(nativeQuery = true,value = "select * from zy_cat_user_task_record where pid=:pid AND task_type=:taskType order by ctime desc limit 1")
	CatDevUserTaskRecord queryByPidAndTaskTypeOrderByTaskType(String pid,int taskType);
}
